cmake_minimum_required(VERSION 3.8)
project(arm_control)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(fruit_detector REQUIRED)
find_package(voice_planner REQUIRED)
find_package(moveit_ros_planning_interface REQUIRED)
find_package(moveit_core REQUIRED)
find_package(moveit_msgs REQUIRED)
find_package(moveit_ros_planning REQUIRED)

# 包含头文件目录
include_directories(include)

# Generate action interfaces
rosidl_generate_interfaces(${PROJECT_NAME}
  "action/ARM.action"
  DEPENDENCIES std_msgs
)

# Add arm_control_node executable
add_executable(arm_control_node 
  src/arm_control_node.cpp
  src/arm_action_type1.cpp
  src/arm_action_type2.cpp
  src/arm_action_type3.cpp
  src/arm_action_type4.cpp
  src/arm_action_type5.cpp
  src/arm_action_type6.cpp
  src/arm_action_type7.cpp
  src/arm_action_type8.cpp
  src/arm_action_type9.cpp
  src/arm_action_type10.cpp
  src/arm_action_type11.cpp
)
ament_target_dependencies(arm_control_node 
  rclcpp 
  rclcpp_action
  std_msgs
  fruit_detector
  voice_planner
  moveit_ros_planning_interface
  moveit_core
  moveit_msgs
  moveit_ros_planning
)


# Add trajectory_publisher_node executable
add_executable(trajectory_publisher_node src/trajectory_publisher_node.cpp)
ament_target_dependencies(trajectory_publisher_node
  rclcpp
  std_msgs
  moveit_msgs
)

# Link generated interfaces
rosidl_get_typesupport_target(cpp_typesupport_target
  ${PROJECT_NAME} rosidl_typesupport_cpp)
target_link_libraries(arm_control_node "${cpp_typesupport_target}")

# Install executables
install(TARGETS
  arm_control_node
  trajectory_publisher_node
  DESTINATION lib/${PROJECT_NAME}
)

# Install header files
install(DIRECTORY include/
  DESTINATION include
)

# Install launch files
install(DIRECTORY launch
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
